#ifndef MAINUI_H
#define MAINUI_H
#include <QWidget>
#include <QTcpSocket>
#include <QHostAddress>
#include <QMessageBox>
#include <QTcpServer>
#include <QSqlDatabase>
#include <QSqlError>
#include <QSqlQuery>
#include <rsa.h>
#include <aes.h>
#include <QDir>
#include <QDebug>
#include <string.h>
#include <iostream>
#include <aes_gcm.h>
#include <diffie_hellman.h>
namespace Ui {
class mainui;
}
struct userkeylist{//定义结构体userlist保存用户名和rsa公钥列表
    QString username;
    QString password;
    int rsae;
    int rsan;
    unsigned char* aeskey;
};

class mainui : public QWidget
{
    Q_OBJECT

public:
    explicit mainui(QWidget *parent = 0);
    ~mainui();
    QSqlDatabase database;
    void createdatabase();
    rsa rsa_a;//解密，签名
    rsa rsa_b;//加密，验证
    QList <userkeylist> ulist;//保存当前用户信息的列表
    int curruentusernum;//当前用户人数
    QByteArray intTo4ByteArray(int i);
    int ByteArray4ToInt(const QByteArray &bytes);
    diffie_hellman DH;
signals:
   void sendsignal_1();
private slots:
    void on_pushButton_clicked();

    void on_start_clicked();

    void on_sendmsg_clicked();

    //客户端和服务器建立连接时，发送信号newConection
    void onNewConnection(void);
    //接收客户端数据的槽函数
    void slotDataReceived(void);
    void slotclientdisconnect(void);
    void sendmsg(QString s,QString username);
    void on_cleartextedit_clicked();
    void qtimeSlot();
    unsigned char* getkey(int k);
private:
    Ui::mainui *ui;
    QTcpServer *server;
    QList <QTcpSocket*> tcpClientList;
    QTimer *timer;
};

#endif // MAINUI_H
